package test3;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

//客户端
public class LoginSelect extends JFrame implements ActionListener {

    JFrame j;
    JPanel p, p1, p2;
    JButton b1, b2, b3, b4;
    JLabel l, l1;
    JTextField t;

    public LoginSelect() {
        j = new JFrame("用户投票");
        j.setBounds(800, 200, 600, 200);
        p = new JPanel(new GridLayout(1, 2));
        p1 = new JPanel(new GridLayout(5, 1));
        p2 = new JPanel(new GridLayout(1, 2));
        b1 = new JButton("投票");
        b2 = new JButton("查询");
        b3 = new JButton("检查是否有人票数相同");
        b4 = new JButton("反馈提交");

        l1 = new JLabel("意见");
        t = new JTextField(20);
        p2.add(l1);
        p2.add(t);
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        b4.addActionListener(this);
        p1.add(b1);
        p1.add(b2);
        p1.add(b3);
        p1.add(b4);
        p1.add(p2);
        l = new JLabel("班花班草选举系统", JLabel.CENTER);
        p.add(l);
        p.add(p1);
        j.add(p);
        j.setVisible(true);
    }


    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == b1) {
            new Choose();
        } else if (e.getSource() == b2) {
            new Total();
        } else if (e.getSource() == b3) {
            new Examine();
        } else if (e.getSource() == b4) {
            try {
                new Send(t.getText());
            } catch (Exception e1) {
                JOptionPane.showMessageDialog(null, "反馈记录");
                System.exit(0);
            }
        }

    }

}

